<template>
  <div class="columnDatail">
    <div class="titleData">
      <div class="imgContainer">
        <img :src="ctx.$fnc.getImgUrl(columnType.avatar)" alt="">
      </div>
      <div class="descTitle">
        <div>
          <h2>{{columnType.title}}</h2>
        </div>
        <div>
          <p>{{columnType.description}}</p>
        </div>
      </div>
    </div>
    <div class="list">
      <colunList :list="typeList"></colunList>
    </div>
  </div>
</template>

<script lang="ts">
import {computed, defineComponent,getCurrentInstance} from 'vue'
import {useRoute} from 'vue-router'
import {testData,testPosts} from '../testData'
import {useStore} from 'vuex'
import colunList from '../components/postList.vue'
export default defineComponent({
  name:'columnDetail',
  components:{
    colunList
  },
  setup(props,context){
    const res:any = getCurrentInstance()
    const ctx = res.ctx
    const route = useRoute()
    const store = useStore()
    const columnId = route.query.id
    // find 方法会直接将数组中 符合条件的 项直接返回回来 且只要有一条符合就直接停止循环
    const columnType = computed(()=>store.getters.getSelectColumnType(columnId))

    const typeList = computed(()=>store.getters.getPostByCid(columnId))
    return {
      columnType,
      typeList,
      ctx
    }
  }
})
</script>

<style lang="less" scoped>
.titleData{
  width: 65%;
  // background-color: skyblue;
  border-bottom: 1px solid #dcdfe6;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 30px 0;
  .imgContainer{
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #dcdfe6;
    >img{
      width: 100%;
      height: 100%;
    }
  }
  .descTitle{
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-left: 30px;
    h2{
      margin-bottom: 30px;
    }
    p{
      font-size: 18px;
    }
  }
}
.list{
  width: 65%;
  margin: 0 auto;
}
</style>